package com.cheyun.netsalev3.viewmodel

import android.content.Intent
import android.view.View
import androidx.lifecycle.MutableLiveData
import com.cheyun.netsalev3.bean.ClueDetails
import com.cheyun.netsalev3.bean.KeyValueParam
import com.cheyun.netsalev3.view.EditCarBuyingRecordActivity
import java.io.Serializable

/**
 * @author Michael
 * @date  2018/12/19 - 9:41.
 */
class CarBuyDetailsActivityViewModel(var data: ClueDetails, var tiCar: Boolean) : BaseViewModel() {
    var listdata = MutableLiveData<List<KeyValueParam>>()
    var imageList = MutableLiveData<List<String>>()

    init {
        setData()
    }

    fun refreshClueDetails(d: ClueDetails){
        data = d;
        setData()
    }

    fun setData(){
        if (tiCar) {
            listdata.postValue(data.liftCarlist)
        } else {
            listdata.postValue(data.buyCarlist)
        }
        imageList.postValue(data.cert_image_url)
    }

    fun editBut(view: View) {
        var intent = Intent(view.context, EditCarBuyingRecordActivity::class.java)
        intent.putExtra("clueDetails", data as Serializable)
        intent.putExtra("tiCar", tiCar)
        view.context.startActivity(intent)
    }
}